package com.example.myspringboot.controller;

import com.example.myspringboot.bean.User;
import com.example.myspringboot.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/login")
    public String checklogin(Model model, User user) {
        User user1 = userMapper.checklogin(user);
        if (user1 != null) {
            return "main.html";
        } else {
            model.addAttribute("msg", "检查用户名和密码");
            return "index.html";
        }
    }
}
